package cn.itcast.springdata.demo;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;

/**
 * @ClassName StringDemo
 * @Description 测试string数据结构
 * @Author 传智播客
 * @Date 17:09 2019/5/9
 * @Version 2.1
 **/
@ContextConfiguration(locations = {"classpath:applicationContext-redis.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
public class StringDemo {
    @Resource
    private RedisTemplate redisTemplate;

    /**
     * @author 栗子
     * @Description 保存或更新
     * @Date 17:11 2019/5/9
     * @param
     * @return void
     **/
    @Test
    public void testSaveOrUpdate(){
        redisTemplate.boundValueOps("username").set("tom");
        redisTemplate.boundValueOps("addr").set("广州");
        redisTemplate.boundValueOps("age").set("20");
    }

    @Test
    public void testGetvalue(){
        System.out.println("username:"+redisTemplate.boundValueOps("username").get());
        System.out.println("addr:"+redisTemplate.boundValueOps("addr").get());
        System.out.println("age:"+redisTemplate.boundValueOps("age").get());
    }
}
